// Tags:
#include <algorithm>
#include <cctype>
#include <cstdio>
#define lowbit(x) (x & -x)

template <typename T>
inline T &read(T &x) {
  x = 0;
  bool f = false;
  short ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = true;
    ch = getchar();
  }
  while (isdigit(ch)) x = x * 10 + (ch ^ '0'), ch = getchar();
  if (f) x = -x;
  return x;
}

const int N = 2e5 + 5, bit = 18;
int n, m, x[N], y[N], f[bit][N], dep[N], v1[N], v2[N];
int e_cnt, heads[N];

struct Edge {
  int v, nxt;
} e[N << 1];

inline void add(int u, int v) {
  e[++e_cnt].v = v, e[e_cnt].nxt = heads[u], heads[u] = e_cnt;
}

void dfs(int u) {
  for (int i = heads[u], v; i; i = e[i].nxt) {
    if ((v = e[i].v) != f[0][u]) {
      f[0][v] = u, dep[v] = dep[u] + 1;
      dfs(v);
    }
  }
}

void solve(int u) {
  for (int i = heads[u], v; i; i = e[i].nxt) {
    if ((v = e[i].v) != f[0][u]) {
      v1[v] += v1[u];
      solve(v);
      v2[u] += v2[v];
    }
  }
}

inline int getlca(int x, int y) {
  if (dep[x] < dep[y]) std::swap(x, y);
  for (int i = bit - 1; ~i; --i) {
    if (dep[f[i][x]] >= dep[y]) x = f[i][x];
  }
  if (x == y) return x;
  for (int i = bit - 1; ~i; --i) {
    if (f[i][x] != f[i][y]) x = f[i][x], y = f[i][y];
  }
  return f[0][x];
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen64("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen64("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("bm.in", "r", stdin);
  freopen("bm.out", "w", stdout);
#endif
#endif

  read(n), read(m);
  for (int i = 1, u, v; i < n; ++i) {
    read(u), read(v);
    add(u, v), add(v, u);
  }
  f[0][1] = 1, dfs(1);
  for (int i = 1; i < bit; ++i) {
    for (int j = 1; j <= n; ++j) { f[i][j] = f[i - 1][f[i - 1][j]]; }
  }
  for (int i = 1, lca; i <= m; ++i) {
    read(x[i]), read(y[i]);
    ++v1[lca = getlca(x[i], y[i])];
    ++v2[x[i]], ++v2[y[i]], --v2[lca];
    if (lca != 1) { --v2[f[0][lca]]; }
  }
  solve(1);
  for (int i = 1, lca; i <= m; ++i) {
    lca = getlca(x[i], y[i]);
    printf("%d\n", v1[x[i]] + v1[y[i]] - v1[lca] * 2 + v2[lca] - 1);
  }
  return 0;
}